/**
 * 
 */
package edu.hit.irlab.tms.datamapping;


import java.io.Serializable;
import java.util.ArrayList;

/**
 * @author chuter
 *
 */
public class Document implements Serializable {
	
	private static final long serialVersionUID = 1986L;
	private ArrayList<Paragraph> paragraphs;
	private ArrayList<Sentence> sentences;
	private ArrayList<Token> tokens;
	
		
	public Document() {
		paragraphs = new ArrayList<Paragraph>();
		sentences = new ArrayList<Sentence>();
		tokens = new ArrayList<Token>();
	} 
	/**
	 * @return the sentences
	 */
	public ArrayList<Sentence> getSentences() {
		return sentences;
	}
	/**
	 * @param sentences the sentences to set
	 */
	public void setSentences(ArrayList<Sentence> sentences) {
		this.sentences = sentences;
	}
	/**
	 * @return the tokens
	 */
	public ArrayList<Token> getTokens() {
		return tokens;
	}
	/**
	 * @param tokens the tokens to set
	 */
	public void setTokens(ArrayList<Token> tokens) {
		this.tokens = tokens;
	}
	
	public ArrayList<Paragraph> getParagraphs() {
		return paragraphs;
	}
	
	public void setParagraphs(ArrayList<Paragraph> paragraphs) {
		this.paragraphs = paragraphs;
	}
	
	/**
	 * Get the next sentence, if the present sentence is the
	 * last one already, it returns null
	 * 
	 * @param present sentence
	 * @return next sentence
	 */
	public Sentence nextSentence(Sentence presentSentence) {
		int senid = presentSentence.getId();
		if (senid >= sentences.size()-1)
			return null;
		return sentences.get(senid+1); 
	}
	
	/**
	 * Get the next token, if the present token is the
	 * last one already, it returns null
	 * 
	 * @param present token
	 * @return next token
	 */
	public Token nextToken(Token presentToken) {
		int tokenid = presentToken.getId();
		if (tokenid >= tokens.size()-1)
			return null;
		return tokens.get(tokenid+1); 
		
	}
	
	/**
	 * Get the next sentence, if the present sentence is the
	 * last one already, it returns null
	 * 
	 * @param present sentence
	 * @return next sentence
	 */
	public Sentence preSentence(Sentence presentSentence) {
		int senid = presentSentence.getId();
		if (senid <= 0)
			return null;
		return sentences.get(senid-1); 
	}
	
	/**
	 * Get the next token, if the present token is the
	 * last one already, it returns null
	 * 
	 * @param present token
	 * @return next token
	 */
	public Token preToken(Token presentToken) {
		int tokenid = presentToken.getId();
		if (tokenid <= 0)
			return null;
		return tokens.get(tokenid-1); 
		
	}
	
	public Token gettoken(int tokenid) {
		if (tokenid >= tokens.size())
			return null;
		return tokens.get(tokenid);
	}
	
	public Sentence getsentence(int senid) {
		if (senid >= sentences.size())
			return null;
		return sentences.get(senid);
	}
	
	public Paragraph getparagraph(int paraid) {
		if (paraid >= paragraphs.size())
			return null;
		return paragraphs.get(paraid);
	}
	
}
